#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
char *as_bytes(int &i);
int main(int argc, char **argv)
{
    if (argc < 3)
    {
        cout << "Usage: " << argv[0] << " input_file output_file" << endl;
        return 0;
    }
    ifstream ifs(argv[1], ios_base::binary);
    if (!ifs)
    {
        cerr << "can't open input file " << argv[1] << endl;
        return 1;
    }
    ofstream ofs(argv[2], ios_base::binary);
    if (!ofs)
    {
        cerr << "can't open output file " << argv[2] << endl;
        return 1;
    }
    vector<int> v;
    for (int x; ifs.read(as_bytes(x), sizeof(int));)
    {
        v.push_back(x);
    }
    for (int x : v)
    {
        ofs.write(as_bytes(x), sizeof(int));
    }
    return 0;
}
char *as_bytes(int &i)
{
    return reinterpret_cast<char *>(&i);
}